#pragma once
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using task_t = function<void()>;

void PrintLog()
{
    cout << "这是一个打印日志" << endl;
}

void DownLoad()
{
    cout << "这是一个下载任务" << endl;
}

void Upload()
{
    cout << "这是一个更新任务" << endl;
}

class TaskManager
{
public:
    TaskManager()
    {
    }

    ~TaskManager()
    {
    }

    int Code()
    {
        return rand() % _task.size();
    }

    void Register(task_t t)
    {
        _task.push_back(t);
    }

    void Execute(int code)
    {
        if (code >= 0 && code < _task.size())
        {
            _task[code]();//这里问题
        }
    }

private:
    vector<task_t> _task;
};